const dev = {
  '/baseApi': {
    target: 'http://localhost:8848', //测试环境
    changeOrigin: true,
    rewrite: (path: any) => path.replace(/^\/baseApi/, '')
  },
  '/chatApi': {
    target: 'http://localhost:8849', //测试环境
    changeOrigin: true,
    rewrite: (path: any) => path.replace(/^\/chatApi/, '/')
  },

}
// 生产环境
const prod = {
  '/baseApi': {
    target: 'http://localhost:8848', 
    changeOrigin: true,
    rewrite: (path: any) => path.replace(/^\/baseApi/, '')
  },
  '/chatApi': {
    target: 'http://localhost:8849', //测试环境
    changeOrigin: true,
    rewrite: (path: any) => path.replace(/^\/chatApi/, '/')
  },
}
// mock
const mock = {
  '/baseApi': {
    target: 'http://localhost:8848', 
    changeOrigin: true,
    rewrite: (path: any) => path.replace(/^\/baseApi/, '')
  },
  '/chatApi': {
    target: 'http://localhost:8849', //测试环境
    changeOrigin: true,
    rewrite: (path: any) => path.replace(/^\/chatApi/, '/')
  },
}

// const env=p => p.env || 'prod' // default to prod if not set or if set to 'dev' or 'prod'
const env = process.env.NODE_ENV || 'production' //如果没有NODE_ENV的话，则使用生产环境。如果你不想测试任何环境，可以将其设置为production。
const getProxy = () => {
  console.log('environment:' + env)
  switch (process.env.NODE_ENV) {
    case 'production':
      return prod
      break
    case 'development':
      return dev
      break
    case 'mock':
      return mock
      break
    default:
      break
  }
}
const Proxy = getProxy()

export default Proxy
